package com.dxc.intern.service.impl;

import com.dxc.intern.entity.Page;
import com.dxc.intern.entity.Resume;
import com.dxc.intern.mapper.ResumeMapper;
import com.dxc.intern.service.ResumeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 简历库 服务实现类
 * </p>
 *
 * @author zhangchengming
 * @since 2022-02-21
 */
@Service
public class ResumeServiceImpl extends ServiceImpl<ResumeMapper, Resume> implements ResumeService {

    @Autowired
    private ResumeMapper resumeMapper;

    @Override
    public Page<Resume> page(Integer pageNo, Integer pageSize) {
        int total =resumeMapper.count();
        int index= pageNo == 1 ? 0 : (pageNo - 1) * pageSize;
        List<Resume> resumes=resumeMapper.page(index,pageSize);
        return new Page<Resume>(pageSize,pageNo,total,resumes);
    }

    @Override
    public Page<Resume> selectLike(Integer pageNo, Integer pageSize, Resume resume) {
        int total =resumeMapper.count();
        int index= pageNo == 1 ? 0 : (pageNo - 1) * pageSize;
        List<Resume> resumes=resumeMapper.selectLike(index,pageSize,resume);
        return new Page<Resume>(pageSize,pageNo,total,resumes);
    }

    @Override
    public boolean delete(Integer id) {
        int i=resumeMapper.delete(id);
        return i>0;
    }

    @Override
    public boolean update(Resume resume) {
        int i=resumeMapper.update(resume);
        return i>0;
    }
}
